/*
 * @Description: 登录 / 退出
 * @Author: DHL
 * @Date: 2021-12-31 14:52:24
 * @LastEditors: DHL
 * @LastEditTime: 2022-10-17 09:08:53
 */
import { LoginUserResultModel } from './model/loginModel'
import { ContentTypeEnum, RequestParams } from '/@/constant/http'
import { Result } from '/@/model/baseModel'
import { $post, $get } from '/@/utils/http'

/**
 * 登录
 * @param params
 * @returns
 */
export const apiLogin = (params: RequestParams) =>
  $post<LoginUserResultModel>({
    url: '/sys/auth/login',
    params: params,
    contentType: ContentTypeEnum.form
  })

/**
 * 刷新登录用户缓存
 * @returns
 */
export const apiLoginRefreshCache = () =>
  $get<LoginUserResultModel>({
    url: '/sys/auth/refreshLoginUserCache'
  })

/**
 * 通过token登录
 */
export const apiLoginByToken = () =>
  $post<LoginUserResultModel>({
    url: '/sys/auth/loginByToken'
  })

/**
 * 退出登录
 * @returns
 */
export const apiLogOut = () =>
  $post<Result<string>>({
    url: '/sys/auth/logOut'
  })

/**
 * 查询登录用户信息
 * @returns
 */
export const apiGetLoginUserCache = () =>
  $get<LoginUserResultModel>({
    url: '/sys/auth/getLoginUserCache'
  })
